package com.dongjiantong.web.boss.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongjiantong.common.model.Response;
import com.dongjiantong.openplatform.annotations.OpenBean;
import com.dongjiantong.openplatform.annotations.OpenMethod;
import com.dongjiantong.user.model.RoleAppUser;
import com.dongjiantong.user.service.RoleAppUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author cao
 * @create 2017-11-30 下午1:52
 **/
//@RestController
//@RequestMapping("/api/boss/role")
@Slf4j
@OpenBean
public class RoleController {

    @Reference(version = "1.0.0")
   public RoleAppUserService roleAppUserService;

    //@GetMapping("/queryRoleAppUser")
    @OpenMethod(
            key = "boss.role.appuser",
            paramNames = {"userId"},
            httpMethods = RequestMethod.GET
    )
    public Response<List<RoleAppUser>> queryRoleAppUser(long userId)
    {
       return Response.ok(roleAppUserService.queryRoleAppByUserId(userId));
    }

    //@GetMapping("/saveRoleAppUser")
    @OpenMethod(
            key = "boss.role.save.RoleAppUser",
            paramNames = {"roleId","userId"},
            httpMethods = RequestMethod.POST
    )
    public void saveRoleAppUser(List<Integer> roleId,long userId)
    {
//        Long userId=3L;
//        RoleAppUser roleAppUser = new RoleAppUser();
//
//        roleAppUser.setUserId(userId);
//        roleAppUser.setAppRole(2006);
//        roleAppUser.setAppRoleName("官方兽医");
//        roleAppUser.setStatus(1);
//        roleAppUser.setCreatedId(1L);
//        roleAppUser.setCreatedAt(new Date());
//
//        List<RoleAppUser> list = new ArrayList<RoleAppUser>();
//        list.add(roleAppUser);
//        roleAppUserService.saveRoleAppUser(userId,list);
    }

}
